package com.candy.demo1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class JDBCDemo {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取连接对象
        String url="jdbc:mysql://localhost:3306/test1";
        String username = "root";
        String password = "root";
        Connection conn = DriverManager.getConnection(url,username,password);

        String sql = "update tb_student set name=? where tid=?";
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.setObject(1,"小艾");
        ps.setObject(2,6);
        ps.executeUpdate();
        ps.close();
        conn.close();
    }
}
